package com.example.shaidemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class ChaHangyeActivity extends AppCompatActivity {
    private List<ChaHangye> salary_list=new ArrayList<>();
    ChaHangyeAdapter chaHangyeAdapter;
    ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cha_hangye);
        toolBar();

        listView=findViewById(R.id.chahangye_list);
        salary_list.add(0,new ChaHangye(1,"技术","5689","25564","25541"));
        salary_list.add(1,new ChaHangye(2,"产品","568","26483","1518"));
        salary_list.add(2,new ChaHangye(3,"人事/财务/行政","452","12736","5648"));
        salary_list.add(3,new ChaHangye(4,"市场","563","19138","2456"));
        salary_list.add(4,new ChaHangye(5,"运营","541","23102","8180"));

        salary_list.add(5,new ChaHangye(6,"销售","758","15897","6091"));
        salary_list.add(6,new ChaHangye(7,"教育培训","589","21156","1299"));
        salary_list.add(7,new ChaHangye(8,"旅游","325","44166","3"));
        salary_list.add(8,new ChaHangye(9,"采购/贸易","256","35714","209"));
        salary_list.add(9,new ChaHangye(10,"高级管理","124","40384","93"));
        salary_list.add(10,new ChaHangye(11,"生产制造","54","31704","143"));

        chaHangyeAdapter = new ChaHangyeAdapter(this, R.layout.list_item_cha_hangye, salary_list);
        listView.setAdapter(chaHangyeAdapter);
        //setListViewHeightBasedOnChildren(listView);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //跳转到详情页
                Intent intent = new Intent(ChaHangyeActivity.this, ChaHangyeDetailActivity.class);
                startActivity(intent);
            }
        });

    }

    public void toolBar(){
        boolean isImmersive = false;


        final TitleBar titleBar = (TitleBar) findViewById(R.id.title_bar);
        titleBar.setBackgroundColor(getResources().getColor(R.color.colorWhite));
        titleBar.setLeftImageResource(R.drawable.ic_left_orange_24dp);
       titleBar.setTitle("查行业");
        titleBar.setLeftText("成都");
        titleBar.setLeftTextSize(18);
        titleBar.setLeftTextColor(getResources().getColor(R.color.colorLightOrange));
        titleBar.setLeftClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                finish();
            }
        });

        titleBar.setTitleColor(Color.BLACK);

        //沉浸式
        titleBar.setImmersive(isImmersive);
    }

}